Add to PATH if we don't need to install#93
Open
TylerLeonhardt wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
rip - works outside of the tests 🙃 probably some magic path stuff. Digging... |
There was a problem hiding this comment.
Pull request overview
This PR updates the DotnetSdk dependency type to ensure the .NET SDK is added to the current session PATH even when installation is skipped because a suitable SDK is already present, and adds/updates tests + error messages to reflect the new behavior.
Changes:
- Always run
.NET SDK -> PATHlogic duringInstallby calling a newImport-Dotnethelper. - Introduce
Import-Dotnet(Private) to centralize PATH/SDK discovery and version validation. - Extend DotnetSdk Pester tests with
Get-Command dotnetassertions and update the expected error message.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Tests/PSModuleGallery.Type.Tests.ps1 | Adds assertions that dotnet is discoverable after Invoke-PSDepend and updates an expected error message. |
| PSDepend/PSDependScripts/DotnetSdk.ps1 | Calls Import-Dotnet during Install and delegates Import behavior to the helper. |
| PSDepend/Private/Import-Dotnet.ps1 | New helper that attempts to ensure a sufficiently new .NET SDK is discoverable via PATH. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $globalDotnetSdkLocation = if ($IsWindowsEnv) { "$env:LocalAppData\Microsoft\dotnet" } else { "$env:HOME/.dotnet" } | ||
|
|
||
| $dotnetInPath = Get-Command 'dotnet' -ErrorAction SilentlyContinue | ||
| $dotnetInPathIsGood = $dotnetInPath -and (Test-Dotnet -Version $Version -InstallDir $dotnetInPath.Source) |
Comment on lines
+89
to
94
|
|
||
| Import-Dotnet -Version $Version -InstallDir $InstallDir | ||
| } | ||
|
|
||
| # Handle 'Import' | ||
| if ($PSDependAction -contains 'Import') { |
Comment on lines
909
to
+911
| Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" -Force | ||
| Test-Path $SavePath | Should -BeTrue | ||
| { Get-Command 'dotnet' } | Should -Not -Throw |
Comment on lines
918
to
+920
| Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" -Force | ||
| Assert-MockCalled -CommandName Install-Dotnet -Times 0 -Exactly | ||
| { Get-Command 'dotnet' } | Should -Not -Throw |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previous logic wouldn't add 'dotnet' to the PATH if it didn't need to be installed (because it was already present).
This will ensure that the .NET SDK is added to the PATH every time you do:
Invoke-PSDependPATHlogic is fun...cc @SeeminglyScience